﻿using Game.Combat;
using Game.Combat.Damage;
using UnityEngine;
using Animator = Core.Animation.Animator;
namespace Game.View {
    public class WeaponDisplay : Collider {
        public Animator Animator {
            get;
            private set;
        }
        
        private Weapon mWeapon;
        public void Init(Weapon weapon) {
            Animator = new Animator(gameObject);
            mWeapon = weapon;
            onInit();
        }

        protected virtual void onInit() { }
        
        protected override void onColliderEnter(Collider2D collider) {
            var hitObj = collider.gameObject.GetComponent<IDamageable>();
            if (hitObj != null) {
                hitObj.AddDamage(new DamageParam() {
                    Type = eDamageType.Weapon
                });
            }
        }
    }
}